/**
 * 进行自动爬取
 */
const env = require('dotenv').config()

// 如果是 生成链接的
const genurl = process.argv.length >= 3;

console.log( (genurl ? "生成配置网址中..." : "生成节假日文件中... ") + new Date().toLocaleString())

/**
 * 引入节假日
 */
 const LegalService = require('./service/legal');

 // 爬取中
 const Legal = new LegalService();

 const startDate = new Date();
 const startTime = startDate.getTime();
 

(async () => genurl ? await Legal.curlQueryLegalUrl() : await Legal.curlLegal())();

 const endDate = new Date();
 const endTime = endDate.getTime();

 console.log(genurl ? "匹配最新的法定节假日公告url" : "爬取成功.... 所用时间为：" ,'\x1B[34m' + (endTime - startTime) + 'ms' + '\x1B[39m');

 genurl ? 
    console.log("生成最新的法定节假日公告url成功: " + Legal.options.url) 
    :
    (console.log("生成配置json 成功 所在路径:") || console.log('\x1B[34m%s\x1B[39m', Legal.options.config_file));



